home *** CD-ROM | disk | FTP | other *** search
/ Mac Mania 4 / MacMania 4.toast / / Demo's / Igor Demo Pro / Igor 68K NoFPU 3.01 Demo Folder / Igor 68K NoFPU 3.01 Demo / Igor 68K NoFPU 3.01 Demo.rsrc / IGPS_2 < prev    next >
Text File  |  1996-04-18  |  10KB  |  506 lines

  1. /IgorSave save def
  2.  
  3. 1000 dict begin
  4.  
  5. 0 setgray 0 setlinecap
  6. 1 setlinewidth 0 setlinejoin
  7. 1 setmiterlimit [] 0 setdash
  8.  
  9. /aw 0 def     /ah 0 def
  10. /x0 0 def    /y0 0 def    /x1 0 def    /y1 0 def
  11. /rx0 0 def    /ry0 0 def    /rx1 0 def    /ry1 0 def
  12. /tmp0 0 def /tmp1 0 def
  13. /packedRed 0 def /packedGreen 0 def /packedBlue 0 def
  14. /x 0 def    /y 0 def    /w 0 def    /c 0 string def
  15.  
  16. /rbak 1 def    /gbak 1 def    /bbak 1 def
  17. /rfor 0 def    /gfor 0 def    /bfor 0 def
  18.  
  19. /bdef{bind def}bind def
  20. /ldef{load def}bdef
  21. /xdef{exch def}bdef
  22.  
  23. /setuserscreendict 22 dict def
  24. setuserscreendict begin
  25.  
  26. /tempctm matrix def
  27. /temprot matrix def
  28. /tempscale matrix def
  29.  
  30. /concatprocs{
  31.     /proc2 exch cvlit def
  32.     /proc1 exch cvlit def
  33.     /newproc proc1 length proc2 length add array def
  34.     newproc 0 proc1 putinterval
  35.     newproc proc1 length proc2 putinterval
  36.     newproc cvx
  37. }def
  38.  
  39. /resmatrix matrix def
  40. /findresolution{
  41.     72 0 resmatrix defaultmatrix dtransform
  42.     /yres xdef /xres xdef
  43.     xres dup mul yres dup mul add sqrt
  44. }def
  45. end
  46.  
  47. /setuserscreen{
  48.   setuserscreendict begin
  49.     /spotfunction xdef
  50.     /screenangle xdef
  51.     /cellsize xdef
  52.     
  53.     /m tempctm currentmatrix def
  54.     /rm screenangle temprot rotate def
  55.     /sm cellsize dup tempscale scale def
  56.     
  57.     sm rm m m concatmatrix m concatmatrix pop
  58.     1 0 m dtransform /y1 xdef /x1 xdef
  59.     /veclength x1 dup mul y1 dup mul add sqrt def
  60.     /frequency findresolution veclength div def
  61.     /newscreenangle y1 x1 atan def
  62.     m 2 get m 1 get mul m 0 get m 3 get mul sub 0 gt
  63.     {
  64.         { neg } /spotfunction load concatprocs
  65.         /spotfunction xdef
  66.     } if
  67.     frequency newscreenangle /spotfunction load setscreen
  68.   end
  69. }def
  70.  
  71. /setpatterndict 18 dict def
  72. setpatterndict begin
  73. /bitison{
  74.     /ybit xdef /xbit xdef
  75.     /bytevalue bstring ybit bwidth mul xbit 8 idiv add get def
  76.     /mask 1 7 xbit 8 mod sub bitshift def
  77.     bytevalue mask and 0 ne
  78. }def
  79. end
  80.  
  81. /bitpatternspotfunction{
  82.   setpatterndict begin
  83.     /y xdef /x xdef
  84.     /xindex x 1 add 2 div bpside mul cvi def
  85.     /yindex y 1 add 2 div bpside mul cvi def
  86.     xindex yindex bitison
  87.     { /onbits onbits 1 add def 1 }
  88.     { /offbits offbits 1 add def 0 }
  89.     ifelse
  90.   end
  91. }def
  92.  
  93. /setpattern{
  94.   setpatterndict begin
  95.     /cellsz xdef
  96.     /angle xdef
  97.     /bwidth xdef
  98.     /bpside xdef
  99.     /bstring xdef
  100.     
  101.     /onbits 0 def /offbits 0 def
  102.     cellsz angle /bitpatternspotfunction load setuserscreen
  103.     {} settransfer
  104.     offbits offbits onbits add div setgray
  105.   end
  106. }def
  107.  
  108. /FillPattern{    % patternstring --
  109.     /pat xdef
  110.     gsave
  111.     pat 8 1 0 72 300 32 div div setpattern
  112.     fill
  113.     grestore
  114. }def
  115.  
  116.  
  117.  
  118. /UseBack{ rbak gbak bbak setrgbcolor }bdef
  119. /UseFore{ rfor gfor bfor setrgbcolor }bdef
  120. /SetBack {/bbak xdef /gbak xdef /rbak xdef }bdef
  121. /SetFore {/bfor xdef /gfor xdef /rfor xdef }bdef
  122.  
  123.  
  124. /ps {setlinewidth} bdef    
  125. /clw {currentlinewidth} bdef
  126. /sd {0 setdash} bdef
  127.  
  128. /mstroke {0 clw eq {newpath}{stroke} ifelse} bdef
  129.  
  130. /_R{ .5 sub round .5 add}bdef
  131. /allign { transform _R exch _R exch itransform }bdef
  132. /L {allign lineto} bdef
  133. /M {allign moveto} bdef
  134.  
  135. /addto { dup load exec 3 -1 roll add store }bdef
  136. /MacLine{        % xto yto xfrom yfrom MacLine --
  137.     newpath        % only handles horizontal or vertical lines
  138.     /y0 xdef /x0 xdef /y1 xdef /x1 xdef
  139.     x1 x0 sub abs
  140.     y1 y0 sub abs gt
  141.     {clw x1 x0 gt {/x1}{/x0}ifelse  addto  clw 2 div dup /y0 addto /y1 addto}
  142.     {clw y1 y0 gt {/y1}{/y0}ifelse  addto  clw 2 div dup /x0 addto /x1 addto}
  143.     ifelse
  144.     x0 y0 M
  145.     x1 y1 L
  146.     mstroke
  147. }bdef
  148.  
  149. /FillPath{        % graylevel FillPath --   fills current path and leaves path alive
  150.     gsave
  151.     dup 1 exch sub        % glev 1-glev
  152.     rbak 2 index mul    rfor 2 index mul add
  153.     gbak 3 index mul    gfor 3 index mul add
  154.     bbak 4 index mul    bfor 4 index mul add
  155.     setrgbcolor
  156.     pop pop
  157.     fill
  158.     grestore
  159. }bdef
  160.  
  161. /StrokePath{        % linejoin StrokePath --   strokes current path and leaves path alive
  162.     gsave
  163.     setlinejoin
  164.     mstroke
  165.     grestore
  166. }bdef
  167.  
  168. /RectPath{        % x0 y0 x1 y1 RectPath -- sets current path to a rectange
  169.     /y1 xdef /x1 xdef /y0 xdef /x0 xdef
  170.     newpath
  171.     x0 y0 M
  172.     x1 y0 L
  173.     x1 y1 L
  174.     x0 y1 L
  175.     closepath
  176. }bdef
  177.  
  178. /PaintRect{        % x0 y0 x1 y1 graylevel PaintRect --
  179.     gsave
  180.     5 1 roll
  181.     RectPath
  182.     FillPath
  183.     grestore
  184. }bdef
  185.  
  186.  
  187.  
  188.  
  189. % **** begin image stuff *****
  190. % The following are used for images. This has to be kept
  191. % in synch with corresponding code in ImageDisp.c.In particular
  192. % the expansion factor, 8, has to be in synch.
  193. % packedcolor is (red*256+green)*256+blue
  194.  
  195. /SetPackedColor{    % packedcolor SetPackedColor --
  196.     dup 256 mod /tmp0 xdef    % extract blue
  197.     256 idiv
  198.     dup 256 mod /tmp1 xdef    % extract green
  199.     256 idiv                 % extract red
  200.     255 div /packedRed xdef
  201.     tmp1 255 div /packedGreen xdef
  202.     tmp0 255 div /packedBlue xdef
  203. }bdef
  204.  
  205. /IR_FillRect{
  206.     gsave
  207.     newpath
  208.     rx0 ry0 M
  209.     rx1 ry0 L
  210.     rx1 ry1 L
  211.     rx0 ry1 L
  212.     closepath
  213.     packedRed packedGreen packedBlue setrgbcolor
  214.     fill
  215.     grestore
  216. }bdef
  217.  
  218. /NewRectImageLine{    % x0 y0 x1 y1 packedcolor NewRectImageLine --
  219.     SetPackedColor
  220.  
  221.     /ry1 xdef /rx1 xdef /ry0 xdef /rx0 xdef    % remember starting rectange for following calls
  222.     
  223.     IR_FillRect
  224. }bdef
  225.  
  226. /rx{        % xdist rx --
  227.     8 div
  228.     dup 0 lt
  229.     { rx0 /rx1 xdef rx1 add /rx0 xdef }        % neg delta steps left
  230.     { rx1 /rx0 xdef rx0 add /rx1 xdef }
  231.     ifelse
  232.     IR_FillRect
  233. }bdef
  234.  
  235. /ry{        % ydist rr --
  236.     8 div
  237.     dup 0 lt
  238.     { ry1 /ry0 xdef ry0 exch sub /ry1 xdef }        % neg delta steps down
  239.     { ry0 /ry1 xdef ry1 exch sub /ry0 xdef }
  240.     ifelse
  241.     IR_FillRect
  242. }bdef
  243.  
  244.  
  245. /cx{        % xdist packedcolor cx --
  246.     SetPackedColor
  247.     rx
  248. }bdef
  249.  
  250. /cy{        % ydist packedcolor cx --
  251.     SetPackedColor
  252.     ry
  253. }bdef
  254.  
  255. % **** end image stuff *****
  256.  
  257.  
  258.  
  259. /EraseRect{        % x0 y0 x1 y1 EraseRect --  fills rect with background color
  260.     gsave
  261.     RectPath
  262.     UseBack fill
  263.     grestore
  264. }bdef
  265.  
  266. /FrameRect{        % x0 y0 x1 y1 FrameRect --
  267.     RectPath
  268.     mstroke
  269. }bdef
  270.  
  271. /FrameMacRect{        % x0 y0 x1 y1 FrameMacRect --  Mac-like version
  272.     RectPath
  273.     mstroke
  274. }bdef
  275.  
  276.  
  277. /ellipse{
  278.     /savematrix matrix currentmatrix def
  279.     translate scale 0 0 1 0 360 arc
  280.     savematrix setmatrix
  281. }bdef
  282.  
  283.  
  284.  
  285. /OvalPath{        % x0 y0 x1 y1 OvalPath -- sets current path to an oval inside rectange
  286.     /y1 xdef /x1 xdef /y0 xdef /x0 xdef
  287.     newpath
  288.     x0 x1 sub abs 2 div y0 y1 sub abs 2 div x0 x1 add 2 div y0 y1 add 2 div ellipse
  289.     closepath
  290. }bdef
  291.  
  292.  
  293. /PaintOval{        % x0 y0 x1 y1 graylevel PaintOval --
  294.     gsave
  295.     5 1 roll
  296.     OvalPath
  297.     FillPath
  298.     grestore
  299. }bdef
  300.  
  301. /EraseOval{        % x0 y0 x1 y1 EraseOval --  fills with background color
  302.     gsave
  303.     OvalPath
  304.     UseBack fill
  305.     grestore
  306. }bdef
  307.  
  308. /FrameOval{        % x0 y0 x1 y1 FrameOval --
  309.     OvalPath
  310.     mstroke
  311. }bdef
  312.  
  313.  
  314. /RRectPath{        % x0 y0 x1 y1 r OvalPath -- sets current path to rounded rectange, radius r
  315.     /radius xdef
  316.     /y1 xdef /x1 xdef /y0 xdef /x0 xdef
  317.     newpath
  318.     x0 radius add y0 M
  319.     x1 y0 x1 y1 radius arcto 4{pop}repeat
  320.     x1 y1 x0 y1 radius arcto 4{pop}repeat
  321.     x0 y1 x0 y0 radius arcto 4{pop}repeat
  322.     x0 y0 x1 y0 radius arcto 4{pop}repeat
  323.     closepath
  324. }bdef
  325.  
  326.  
  327. /PaintRRect{        % x0 y0 x1 y1 r graylevel PaintRRect --
  328.     gsave
  329.     6 1 roll
  330.     RRectPath
  331.     FillPath
  332.     grestore
  333. }bdef
  334.  
  335. /EraseRRect{        % x0 y0 x1 y1 r EraseRRect --  fills rect with background color
  336.     gsave
  337.     RRectPath
  338.     UseBack fill
  339.     grestore
  340. }bdef
  341.  
  342. /FrameRRect{        % x0 y0 x1 y1 r FrameRect --
  343.     RRectPath
  344.     mstroke
  345. }bdef
  346.  
  347.  
  348.  
  349.  
  350. /CapLine{        % x0 y0 x1 y1 linecap CapLine -- draws line using given line cap
  351.     gsave
  352.     setlinecap
  353.     /y1 xdef /x1 xdef /y0 xdef /x0 xdef
  354.     newpath
  355.     x0 y0 M
  356.     x1 y1 L
  357.     mstroke
  358.     grestore
  359. }bdef
  360.  
  361. /Arrow{        % x0 y0 x1 y1 width height graylevel Arrow -- draws arrow at end of line from P0 to P1
  362.     gsave
  363.     /gl xdef 1 add /aw xdef 1 add /ah xdef /y0 xdef /x0 xdef /y1 xdef /x1 xdef 
  364.     x0 y0 translate
  365.     /x1 x1 x0 sub def
  366.     /y1 y1 y0 sub def
  367.     y1 x1 atan rotate
  368.     newpath
  369.     0 0 M
  370.     aw ah 2 div L
  371.     aw ah 2 div neg L
  372.     closepath
  373.     gl FillPath
  374. %    10 setmiterlimit
  375. %    1 ps
  376. %    0 StrokePath
  377.     grestore
  378. }bdef
  379.  
  380.  
  381. % ************ fonts ************
  382.  
  383.  
  384. /normal 0 def
  385. /bold 1 def
  386. /italic 2 def
  387. /underline 4 def
  388. /outline 8 def
  389. /shadow 16 def
  390.  
  391. /FACE1 bold italic or def
  392. /FACE2 outline shadow or def
  393.  
  394. /Shadow {
  395.     gsave
  396.     siz 0.08 mul 1 index mul x add
  397.     exch siz 0.07 mul mul y add M
  398.     c show
  399.     grestore
  400. } def
  401.  
  402. /Outline {
  403.     gsave
  404.     siz .02 mul setlinewidth
  405.     x y M c true charpath
  406.     gsave UseBack fill grestore stroke
  407.     grestore
  408. } def
  409.  
  410. /Underline{
  411.     gsave
  412.     siz 0.08 mul ps
  413.     x y clw add M x c stringwidth pop add y clw add L stroke
  414.     grestore
  415. }bdef
  416.  
  417. /DoShow{    % assumes x,y,c are already set
  418.     fontkind FACE2 and
  419.     dup normal eq                 {c x y M show} if
  420.     dup outline eq                 {Outline} if
  421.     dup shadow eq                 {1 Shadow Outline} if
  422.     outline shadow or eq         {1 Shadow 1.5 Shadow Outline} if
  423.     fontkind underline and 0 ne { Underline } if
  424. }bdef
  425.  
  426. /DoWShow{    % assumes x,y,c & w are already set
  427.     gsave
  428.     x y translate
  429.     /x 0 def  /y 0 def
  430.     w c stringwidth pop div 1 scale
  431.     DoShow
  432.     grestore
  433. }bdef
  434.  
  435. /S{
  436.     /y xdef /x xdef /c xdef
  437.     DoShow
  438. }bdef
  439.  
  440. /WS{        % string x y desiredwidth WS -
  441.     /w xdef /y xdef /x xdef /c xdef
  442.     DoWShow
  443. }bdef
  444.  
  445. /F{
  446.     /fontkind xdef
  447.     findfont exch /siz xdef [siz 0 0 siz neg  0 0] makefont setfont
  448. }bdef
  449.  
  450.  
  451.  
  452. /Re-encode {
  453.     dup length array copy
  454.     /eap 0 def
  455.     exch {
  456.         dup type /integertype eq
  457.         { /eap xdef }
  458.         {
  459.             1 index
  460.             exch
  461.             eap exch
  462.             put
  463.             /eap eap 1 add def
  464.         }
  465.         ifelse
  466.     } forall
  467. } bind def
  468.  
  469. [ 39/quotesingle 96/grave 128/Adieresis/Aring/Ccedilla/Eacute/Ntilde/Odieresis
  470. /Udieresis/aacute/agrave/acircumflex/adieresis/atilde/aring/ccedilla/eacute
  471. /egrave/ecircumflex/edieresis/iacute/igrave/icircumflex/idieresis/ntilde
  472. /oacute/ograve/ocircumflex/odieresis/otilde/uacute/ugrave/ucircumflex
  473. /udieresis/dagger/degree/cent/sterling/section/bullet/paragraph/germandbls
  474. /registered/copyright/trademark/acute/dieresis/.notdef/AE/Oslash
  475. /.notdef/plusminus/.notdef/.notdef/yen/mu/.notdef/.notdef
  476. /.notdef/.notdef/.notdef/ordfeminine/ordmasculine/.notdef/ae/oslash
  477. /questiondown/exclamdown/logicalnot/.notdef/florin/.notdef/.notdef
  478. /guillemotleft/guillemotright/ellipsis/.notdef/Agrave/Atilde/Otilde/OE/oe
  479. /endash/emdash/quotedblleft/quotedblright/quoteleft/quoteright/divide
  480. /.notdef/ydieresis/Ydieresis/fraction/currency/guilsinglleft/guilsinglright
  481. /fi/fl/daggerdbl/periodcentered/quotesinglbase/quotedblbase/perthousand
  482. /Acircumflex/Ecircumflex/Aacute/Edieresis/Egrave/Iacute/Icircumflex
  483. /Idieresis/Igrave/Oacute/Ocircumflex/.notdef/Ograve/Uacute/Ucircumflex
  484. /Ugrave/dotlessi/circumflex/tilde/macron/breve/dotaccent/ring/cedilla
  485. /hungarumlaut/ogonek/caron]
  486. /zzz xdef
  487.  
  488. /OurEncoding{ zzz StandardEncoding Re-encode }bdef
  489.  
  490. /EncodeFont    {
  491.     findfont
  492.     dup length dict begin
  493.     {
  494.         1 index /FID ne
  495.         { def }
  496.         { pop pop }
  497.         ifelse
  498.     } forall
  499.     /FontName xdef
  500.     /Encoding xdef
  501.     FontName currentdict
  502.     end
  503.     definefont pop
  504. } bind def
  505.  
  506.